package collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class SortString {
    public static void main(String[] args) {
        List<String> list = new ArrayList<String>();
        list.add("jack");
        list.add("queen");
        list.add("king");
        list.add("queen");
        list.add("king");
        list.add("kobe");
        list.add("jerry");

        System.out.println(list);

        Collections.sort(list);
        System.out.println(list);


        List<String> list1 = new ArrayList<>();
        list1.add("王老师");
        list1.add("传奇老师");
        list1.add("老师");
        Collections.sort(list1, new Comparator<String>() {
            public int compare(String o1, String o2) {
                return o1.length() - o2.length();
            }
        });
        Collections.sort(list1, (o1, o2) -> o1.length() - o2.length()
        );
    }
}
